package com.ruoyi.system.controller;

import java.util.List;

import com.ruoyi.system.service.IRepBaseService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RepPro;
import com.ruoyi.system.service.IRepProService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报分类汇总信息Controller
 * 
 * @author renfx
 * @date 2021-09-10
 */
@RestController
@RequestMapping("/system/repPro")
public class RepProController extends BaseController
{
    @Autowired
    private IRepProService repProService;

    @Autowired
    private IRepBaseService repBaseService;

    /**
     * 查询报分类汇总信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:repPro:list')")
    @GetMapping("/list")
    public TableDataInfo list(RepPro repPro)
    {
        startPage();
        List<RepPro> list = repProService.selectRepProList(repPro);
        return getDataTable(list);
    }

    /**
     * 导出报分类汇总信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:repPro:export')")
    @Log(title = "报分类汇总信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RepPro repPro)
    {
        List<RepPro> list = repProService.selectRepProList(repPro);
        ExcelUtil<RepPro> util = new ExcelUtil<RepPro>(RepPro.class);
        return util.exportExcel(list, "报分类汇总信息数据");
    }

    /**
     * 获取报分类汇总信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:repPro:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(repProService.selectRepProById(id));
    }

    /**
     * 新增报分类汇总信息
     */
    @PreAuthorize("@ss.hasPermi('system:repPro:add')")
    @Log(title = "报分类汇总信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RepPro repPro)
    {
        return toAjax(repProService.insertRepPro(repPro));
    }

    /**
     * 修改报分类汇总信息
     */
    @PreAuthorize("@ss.hasPermi('system:repPro:edit')")
    @Log(title = "报分类汇总信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RepPro repPro)
    {
        return toAjax(repProService.updateRepPro(repPro));
    }

    /**
     * 删除报分类汇总信息
     */
    @PreAuthorize("@ss.hasPermi('system:repPro:remove')")
    @Log(title = "报分类汇总信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(repProService.deleteRepProByIds(ids));
    }

    /**
     * 获取报分类汇总信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:repPro:showrep')")
    @GetMapping("/geRepBase/{id}")
    public AjaxResult geRepBase(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(repBaseService.selectRepBaseById(id));
    }

}
